#include <iostream>
#include <cmath>

void radiansTest()
{
    double radians =0.0526;
    double degrees = radians * (180.0 / M_PI);

    std::cout << radians << " 弧度等于 " << degrees << " 度" << std::endl;

    // 使用三角函数
    double sin_value = sin(radians);
    double cos_value = cos(radians);
    double tan_value = tan(radians);

    std::cout << "sin(" << radians << ") = " << sin_value << std::endl;
    std::cout << "cos(" << radians << ") = " << cos_value << std::endl;
    std::cout << "tan(" << radians << ") = " << tan_value << std::endl;

    // 反三角函数
    double asin_value = asin(sin_value);
    double acos_value = acos(cos_value);
    double atan_value = atan(tan_value);

    std::cout << "asin(" << sin_value << ") = " << asin_value << " 弧度" << std::endl;
    std::cout << "acos(" << cos_value << ") = " << acos_value << " 弧度" << std::endl;
    std::cout << "atan(" << tan_value << ") = " << atan_value << " 弧度" << std::endl;

    // 使用 atan2 函数
    double x = 0.98;
    double y = -2.98;
    double atan2_value = atan2(y, x);
    std::cout << "atan2(" << y << ", " << x << ") = " << atan2_value << " 弧度" << std::endl;
}

int main()
{
    double wx = 0.01;
    bool result = std::abs(wx) < std::numeric_limits<double>::epsilon();
    std::cout << "wx 是否接近于 0: " << result << std::endl;

    radiansTest();

    double degrees =5.0;
    double radians = degrees * (M_PI / 180.0);
    std::cout << degrees << " 度等于 " << radians << " 弧度" << std::endl;

    //计算距离
    double x1 =3.875,y1= -2.06;
    double x2=3.956,y2=-2.015;
    double distance = std::hypot(x2 - x1, y2 - y1);
    std::cout << "两点之间的距离是 " << distance << std::endl;
    return 0;
}